import request from "@/utils/request";
import { rootsUrl } from "../utils";
import { getToken } from "@/utils/auth";

/**
 * 获取commonDetail页面的详情
 * @param {number} id
 */
export const getDetail = id => {
  return request({
    url: `${rootsUrl[0]}/museum/contentManage/getContentDetailById.shtml`,
    method: "get",
    params: {
      id: id
    }
  });
};

/**
 *  获取典藏详情
 * @param {Number} sid
 */
export const getCollectionDetailBySid = id => {
  return request({
    url: `${rootsUrl[0]}/museum/collection/getCollectionById.shtml`,
    method: "get",
    params: {
      id
    }
  });
};

/**
 * 获取文创商品详情
 * @param {Number} id 文创商品的id
 */
export const getCultureProdDetail = id => {
  return request({
    url: `${rootsUrl[3]}/cbculture/prod/getProdDetails.shtml`,
    method: "get",
    params: {
      id
    }
  });
};

/**
 * 获取公告
 */
export const getNotice = () => {
  return request({
    url: `${rootsUrl[0]}/museum/notice/listNotice.shtml`,
    method: "get"
  });
};

/**
 * 获取浏览量
 * @param  id 文章Id
 */
export const getBrowseNum = (id, type) => {
  return request({
    url: `${rootsUrl[0]}/museum/browsevol/countBrowse.shtml`,
    method: "get",
    params: {
      type: type || "3",
      id: id
    }
  });
};

/**
 * 获取浏览次数
 * @param {} id 文章Id
 * @param {*} type
 * 1, "后台系统-典藏概况"),
 * 2, "文创商品"),
 * 3, "栏目内容"),
 * 4, "特殊展览");
 * 5,“征集作品”
 * 6 征集活动
 * 7.文创投票活动
 */
export const addBrowseNum = (id, type) => {
  let token = getToken();
  return request({
    url: `${rootsUrl[0]}/museum/browsevol/addBrowse.shtml`,
    method: "get",
    params: {
      type,
      id: id,
      token,
      sys: "2"
    }
  });
};

/**
 * 获取公告
 */
export const getStudyNoticeList = () => {
  return request({
    url: `${rootsUrl[1]}/cbeducate/notice/getNoticeList.shtml`,
    method: "get"
  });
};

/**
 * 获取公告
 */
export const getPaper = () => {
  return request({
    url: `${rootsUrl[0]}/museum/qsTopic/getQuestionsUrl.shtml`,
    method: "get"
  });
};
